using System;
using System.ComponentModel;
using System.Linq.Expressions;

namespace VisualWip.Core.Utils
{
    public static class PropertyHelper
    {
        public static void OnPropertyChanged<T>(object sender, PropertyChangedEventHandler eventHandler,
                                                params Expression<Func<T>>[] property)
        {
            if (eventHandler != null)
                foreach (var propertyExpression in property)
                {
                    eventHandler(sender,
                                 new PropertyChangedEventArgs(((MemberExpression) propertyExpression.Body).Member.Name));
                }
        }

        public static string Name<T>(Expression<Func<T>> property)
        {
            return ((MemberExpression) property.Body).Member.Name;
        }
    }
}